package com.ailanyin.admin.config;


import com.ailanyin.common.config.BaseSwaggerConfig;
import com.ailanyin.common.model.SwaggerProperties;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * Knife4j 接口文档配置
 *
 * @author ailanyin
 * @version 1.0
 * @since 2021/10/15 0015 下午 16:43
 */
@Configuration
@EnableSwagger2
public class Knife4jConfig extends BaseSwaggerConfig {


    @Value("${spring.profiles.active}")
    private String active;

    private static final String DEV = "dev";

    @Override
    public SwaggerProperties swaggerProperties() {

        if (DEV.equals(active)) {
            return SwaggerProperties.builder()
                    .apiBasePackage("com.ailanyin.admin.controller")
                    .title("ailanyin-boot-mysql8")
                    .description("相关接口文档")
                    .contactName("ailanyin")
                    .version("dev")
                    .enableSecurity(true)
                    .build();
        }
        return SwaggerProperties.builder()
                .apiBasePackage("com.controller")
                .title("生产环境开发文档已经关闭")
                .description("生产环境开发文档已经关闭")
                .contactName("ailanyin")
                .version("prod")
                .enableSecurity(false)
                .build();
    }
}
